#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
struct node{
    int r;
    bool used=false;
    friend bool operator <(node a,node b){
        return a.r<b.r;
    }
}a[N];
int n,ans,cnt;
int first[N],len[N],hack[N];
int read()
{
    int f=1,x=0;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return f*x;
}
signed main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    ans=n;
    for(register int i=1;i<=n;i++)
        a[i].r=read();
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        if(!first[a[i].r])
        {
            cnt++;
            first[a[i].r]=i;
        }
        len[a[i].r]++;
        hack[a[i].r]=i+1;
    }
    memset(first,0,sizeof(first));
    for(int i=1;hack[a[i].r]<=n;)
    {
        if(len[a[hack[a[i].r]].r]>=len[a[i].r])
        {
            ans-=len[a[i].r];
            if(first[a[i].r])
                i=first[a[i].r];
            else
                i=hack[a[i].r];
        }
        else
        {
            if(!first[a[i].r])
                first[a[i].r]=hack[a[i].r];
            ans-=len[a[hack[a[i].r]].r];
            len[a[i].r]-=len[a[hack[a[i].r]].r];
            hack[a[i].r]=hack[a[hack[a[i].r]].r];
        }
    }
    cout<<ans<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
